import result from '/@utils/Axios.ts'

// 板块列表
export function board_list() {
    return result({
        url: '/api/forum/boards/',
        method: 'get',
    })
}

// 创建板块
export function board_create(data: any) {
    return result({
        url: '/api/forum/boards/',
        method: 'post',
        data
    })
}

// 更新板块
export function board_update(id: number, data: any) {
    return result({
        url: `/api/forum/boards/${id}/`,
        method: 'put',
        data
    })
}

// 删除板块
export function board_delete(id: number) {
    return result({
        url: `/api/forum/boards/${id}/`,
        method: 'delete',
    })
}

// 主题列表
export function topic_list(params: any) {
    return result({
        url: '/api/forum/topics/',
        method: 'get',
        params
    })
}

// 创建主题
export function add_topics(data: any) {
    return result({
        url: '/api/forum/topics/',
        method: 'post',
        data
    })
}

// 更新主题
export function put_topics(id: number, data: any) {
    return result({
        url: `/api/forum/topics/${id}/`,
        method: 'put',
        data
    })
}

// 删除主题
export function del_topic(id: number) {
    return result({
        url: `/api/forum/topics/${id}/`,
        method: 'delete',
    })
}

// 设置精华主题
export function topic_essence(id: number) {
    return result({
        url: `/api/forum/topics/essence/${id}/`,
        method: 'post',
    })
}

// 置顶主题
export function topic_pin(id: number) {
    return result({
        url: `/api/forum/topics/pin/${id}/`,
        method: 'post',
    })
}

// 回复列表
export function reply_list(params: {
    page?: number
    page_size?: number
    topic_id?: number
    author_id?: number
}) {
    return result({
        url: '/api/forum/replies/',
        method: 'get',
        params
    })
}

// 删除回复
export function reply_delete(id: number) {
    return result({
        url: `/api/forum/replies/${id}/`,
        method: 'delete',
    })
}

export function user_search(params: {username: string}) {
    return result({
        url: '/api/hzadmin/user/list/',
        method: 'get',
        params
    })
}


//热门主题
export function hot_rankings(params: any = {}){
    return result({
        url: '/api/forum/topics/hot_ranking/',
        method: 'get',
        params: params
    })
}

//主题点赞
export function topic_like(id: number){
    return result({
        url: `/api/forum/topics/like/${id}/`,
        method: 'post'
    })
}

//回复主题
export function topic_replies(data: any){
    return result({
        url: '/api/forum/replies/',
        method: 'post',
        data
    })
}

export function view_topic(id: number){
    return result({
        url: `/api/forum/topics/view_count/${id}/`,
        method: 'post'
    })
}
